namespace ConsoleApp3._1014;

public class Student
{
    private int id;
    private string name;
    private string gender;
    private int age;

    public Student()
    {
    }

    public Student(int id, string name, string gender, int age)
    {
        this.id = id;
        this.name = name;
        this.gender = gender;
        this.age = age;
    }
    
    
    public int Id
    {
        get { return id; }
        set
        {
            if (value < 0)
                throw new ArgumentException("学号不能为负数");
            id = value;
        }
    }

    public string Name
    {
        get { return name; }
        set
        {
            if (string.IsNullOrWhiteSpace(value))
                throw new ArgumentException("姓名不能为空");
            name = value;
        }
    }

    public string Gender
    {
        get { return gender; }
        set
        {
            if (value != "男" && value != "女" && value != "未知")
                throw new ArgumentException("性别只能是'男'、'女'或'未知'");
            gender = value;
        }
    }

    public int Age
    {
        get { return age; }
        set
        {
            if (value < 1 || value > 150)
                throw new ArgumentException("年龄必须在1-150之间");
            age = value;
        }
    }
    
    public override string ToString()
    {
        return $"学号：{Id}，姓名：{Name}，性别：{Gender}，年龄：{Age}";
    }
}


